import 'package:flutter/material.dart';
import 'package:osc/res/colors.dart';
import 'package:osc/res/dimens.dart';
import 'package:osc/utils/navigator_util.dart';
import 'package:osc/utils/pd_util.dart';

class AboutUsPage extends StatelessWidget{
  final List<Item> items = [Item("公司介绍", "about"), Item("平台优势", "about/advantage"), Item("隐私协议", "Protocol/terms")];

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: Text('关于我们'),
        centerTitle: true,
      ),
      body: ListView.separated(
          itemBuilder: (BuildContext context, int index){
            return buildItem(context, items.elementAt(index));
          },
          separatorBuilder: (BuildContext context, int index){
            return Container(color: Colours.divider, height: Dimens.gap_divider_height_smallest,);
          },
          itemCount: items.length
      ),
    );
  }

  buildItem(BuildContext context, Item item){
    return GestureDetector(
      onTap: (){
        jump2Web(context, PdUtil.getFullUrl(item.url), item.title);
      },
      child: Container(
        color: Colors.white,
        padding: EdgeInsets.symmetric(vertical: Dimens.gap_view_bigger, horizontal: Dimens.gap_activity_horizontal),
        child: Row(
          children: <Widget>[
            Expanded(child: Text(item.title, style: TextStyle(color: Colours.gray_33, fontSize: Dimens.font_sp12),)),
            buildArrowRight()
          ],
        ),
      ),
    );
  }

  buildArrowRight(){
    return Padding(
      padding: EdgeInsets.only(left: Dimens.gap_view_normal),
      child: Image.asset("images/icon_arrow_right.png", width: 10,),
    );
  }

  jump2Web(BuildContext context, String url, String title){
    NavigatorUtil.pushWeb(context, url: url, title: title);
  }
}

class Item{
  String title;
  String url;

  Item(this.title, this.url);
}